package cn.edu.scujcc.dpl;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.andremion.music.MusicCoverView;

public class playerActivity extends AppCompatActivity {
    private MusicCoverView mCoverView;
    private ImageView playImage;
    private SeekBar seekBar;
    private TextView textView;

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.player);
            seekBar = (SeekBar) findViewById(R.id.sk);
            textView = (TextView) findViewById(R.id.textView2);
            seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    // 当拖动条的滑块位置发生改变时触发该方法,在这里直接使用参数progress，即当前滑块代表的进度值
                    textView.setText("音量:" + Integer.toString(progress));
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                    Log.e("------------", "开始滑动！");
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    Log.e("------------", "停止滑动！");
                }

            });


            mCoverView =  findViewById(R.id.img1);
            playImage = findViewById(R.id.play_btn);
            playImage.setOnClickListener(v -> {
                if (mCoverView.isRunning()) {  //判断转动，如果转动则停止
                    mCoverView.stop();
                } else {
                    mCoverView.morph();
                }
            });

            mCoverView.setCallbacks(new MusicCoverView.Callbacks() {

                @Override
                public void onMorphEnd(MusicCoverView coverView) {
                    Log.d("TEST", "原型吗？"+(MusicCoverView.SHAPE_CIRCLE == coverView.getShape()));
                    if (MusicCoverView.SHAPE_CIRCLE == coverView.getShape()) {
                        coverView.start();
                    }
                }

                @Override
                public void onRotateEnd(MusicCoverView coverView) {
                    coverView.morph();
                }
            });

            ImageView btn = findViewById(R.id.btnx);
            btn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v){
                    Intent it = new Intent();
                    it.setClass(playerActivity.this,MainActivity.class);
                    playerActivity.this.startActivity(it);
                }
            });
        }
}

